package com.nameli.admin.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.nameli.SIM.bean.query.FacultyQuery;
import com.nameli.SIM.bean.vo.FacultyVO;
import com.nameli.SIM.mapper.FacultyInfoMapper;
import com.nameli.admin.service.FacultyService;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.Map;

/**
 * @author NAME-L
 * @Description 院系ServiceImpl
 * @className FacultyServiceImpl
 * @date 2021-11-05 15:18:45
 */
@Component
public class FacultyServiceImpl implements FacultyService {

    private static final Log log = LogFactory.getLog(FacultyServiceImpl.class);

    @Autowired
    private FacultyInfoMapper facultyInfoMapper;



    @Override
    public int queryByDepartmentNo(String departmentNo) {
        int count = facultyInfoMapper.queryByDepartmentNo(departmentNo);
        return count;
    }

    @Override
    public List<Map<String, Object>> queryByDepartNo(String departNo) {
        List<Map<String, Object>> list = facultyInfoMapper.queryByDepartNo(departNo);
        return list;
    }

    @Override
    public PageInfo<FacultyVO> queryAllFaculty(Integer pageIndex , Integer pageSize) {
        PageHelper.startPage(pageIndex, pageSize);
        List<FacultyVO> facultyVOS = facultyInfoMapper.queryAllFaculty();
        log.info("output -----------> facultyVOS:" + facultyVOS);
        PageInfo<FacultyVO> pageInfo = new PageInfo<>(facultyVOS);
        return pageInfo;
    }

    @Override
    public PageInfo<FacultyVO> queryByCondition(FacultyQuery facultyQuery ,Integer pageIndex , Integer pageSize) {
        PageHelper.startPage(pageIndex, pageSize);
        List<FacultyVO> facultyVOS = facultyInfoMapper.queryByCondition(facultyQuery);
        log.info("output -----------> facultyVOS:" + facultyVOS);
        PageInfo<FacultyVO> pageInfo = new PageInfo<>(facultyVOS);
        return pageInfo;
    }
}
